package com.binance.gateway.config;

import java.util.Collections;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.cloud.netflix.zuul.filters.route.RibbonCommandFactory;
import org.springframework.cloud.netflix.zuul.filters.route.ZuulFallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.binance.gateway.ribbon.BinanceHttpClientRibbonCommandFactory;

@Configuration
@SuppressWarnings("deprecation")
public class RibbonConfig {
    @Autowired(required = false)
    private Set<ZuulFallbackProvider> zuulFallbackProviders = Collections.emptySet();

    @Bean
    @ConditionalOnMissingBean
    public RibbonCommandFactory<?> ribbonCommandFactory(SpringClientFactory clientFactory,
            ZuulProperties zuulProperties) {
        return new BinanceHttpClientRibbonCommandFactory(clientFactory, zuulProperties, zuulFallbackProviders);
    }
}
